package celiasoft.itasalib.structures;

import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import celiasoft.itasalib.staticdata.ItasaStaticUrls;

public class Show extends DataElement {
	
	/* essential */
	private int _fans;
	private Date _start;
	private Date _end;
	
	/* extra */
	private ShowExtraData _extra;
	
	public Show(int id, String name) {
		super(id,name);
		this._extra = new ShowExtraData();
	}

	/**
	 * @return the fans
	 */
	public int getFans() {
		return _fans;
	}
	
	/**
	 * @param fans the fans to set
	 */
	public void setFans(int fans) {
		_fans = fans;
	}

	/**
	 * @return the start
	 */
	public Date getStart() {
		return _start;
	}

	/**
	 * @param start the start to set
	 */
	public void setStart(Date start) {
		if(start == null){
			_start = new Date(0L);
		}else{
			_start = start;
		}
	}

	/**
	 * @return the end
	 */
	public Date getEnd() {
		return _end;
	}

	/**
	 * @param end the end to set
	 */
	public void setEnd(Date end) {
		if(end == null){
			_end = new Date(0L);
		}else{
			_end = end;
		}
	}
	
	
	/* EXTRA */
	public void setExtraShowData(ShowExtraData extra){
		this._extra = extra;
	}
	
	public ShowExtraData getExtraData(){
		return this._extra;
	}
	
	/**
	 * @return the idTvdb
	 */
	public int getIdTvdb() {
		return this._extra.getIdTvdb();
	}

	/**
	 * @return the idTvrage
	 */
	public int getIdTvrage() {
		return this._extra.getIdTvrage();
	}

	/**
	 * @return the nameTvdb
	 */
	public String getNameTvdb() {
		return this._extra.getNameTvdb();
	}

	/**
	 * @return the nameTvrage
	 */
	public String getNameTvrage() {
		return this._extra.getNameTvrage();
	}

	/**
	 * @return the plot
	 */
	public String getPlot() {
		return this._extra.getPlot();
	}

	/**
	 * @return the plotLang
	 */
	public String getPlotLang() {
		return this._extra.getPlotLang();
	}

	/**
	 * @return the banner
	 */
	public URL getBanner() {
		return this._extra.getBanner();
	}

	/**
	 * @return the lastUpdate
	 */
	public Date getLastUpdate() {
		return this._extra.getLastUpdate();
	}

	/**
	 * @return the folderThumb
	 */
	public URL getFolderThumb() {
		return this._extra.getFolderThumb();
	}

	/**
	 * @return the actors
	 */
	public List<Actor> getActors() {
		return this._extra.getActors();
	}

	/**
	 * @return the genres
	 */
	public String getGenres() {
		return this._extra.getGenres();
	}

	/**
	 * @return the season
	 */
	public int getSeason() {
		return this._extra.getSeason();
	}

	/**
	 * @return the classification
	 */
	public String getClassification() {
		return this._extra.getClassification();
	}

	/**
	 * @return the country
	 */
	public String getCountry() {
		return this._extra.getCountry();
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return this._extra.getStatus();
	}

	/**
	 * @return the network
	 */
	public String getNetwork() {
		return this._extra.getNetwork();
	}

	/**
	 * @return the runtime
	 */
	public int getRuntime() {
		return this._extra.getRuntime();
	}

	/**
	 * @return the airdate represented by an integer stands for a week day's number: from Monday (0) to Sunday (6). Or -1.
	 */
	public int getAirday() {
		return this._extra.getAirday();
	}

	/**
	 * @return the airtime
	 */
	public Date getAirtime() {
		return this._extra.getAirtime();
	}

	/**
	 * @return the lastepNum
	 */
	public EpisodeData getLastEpNum() {
		return this._extra.getLastEpNum();
	}

	/**
	 * @return the lastepTitle
	 */
	public String getLastEpTitle() {
		return this._extra.getLastEpTitle();
	}

	/**
	 * @return the lastepDate
	 */
	public Date getLastEpDate() {
		return this._extra.getLastEpDate();
	}
	
	/**
	 * @return the nextepNum
	 */
	public EpisodeData getNextEpNum() {
		return this._extra.getNextEpNum();
	}
	
	/**
	 * @return the nextepTitle
	 */
	public String getNextEpTitle() {
		return this._extra.getNextEpTitle();
	}

	/**
	 * @return the nextepDate
	 */
	public Date getNextEpDate() {
		return this._extra.getNextEpDate();
	}

	/* (non-Javadoc)
	 * @see celiasoft.itasalib.structures.DataElement#getLink()
	 */
	@Override
	public String getLink() {
		return String.format(Locale.ITALY, ItasaStaticUrls.BASE_URL_SERIES_WEB_PAGE, this.getId());
	}
	
	/**
	 * @return a link to sub's web page at italiansubs.net or the same link returned by getLink() if there is no data on last EpisodeData.
	 */
	public String getLastSubLink() {
		String link = this.getLink();
		if(this.getLastEpNum() != null){
			link = String.format(Locale.ITALY, ItasaStaticUrls.BASE_URL_SUBS_WEB_PAGE, this.getId(), this.getLastEpNum().getSeason(), this.getLastEpNum().getEpisode());
		}
		return link;
	}
}
